package cn.com.open.itembank.service;

import cn.com.open.itembank.dto.QuestionTypeDto;
import cn.com.open.itembank.dto.QuestionTypeManageDto;
import cn.com.open.itembank.dto.ReturnModel;
import cn.com.open.itembank.entity.QuestionType;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by lucky on 2017/9/4.
 */
@FeignClient(name = "item-base-service")
public interface QuestionTypeRemoteService {

    /**
     * 根据题型id获取题型信息.
     *
     * @param id 题型id
     * @return 题型信息
     */
    @GetMapping(value = "/questionType/{id}")
    QuestionType getQuestionType(@PathVariable(value = "id") String id);

    /**
     * 根据题库ID获取题型列表(admin).
     *
     * @param itemBankId 题库id
     * @param name       题型名称模糊查询
     * @return the list by item bank id and name
     */
    @GetMapping(value = "/itemBank/{id}/questiontypelist")
    List<QuestionTypeManageDto> getListByItemBankIdAndName(@PathVariable(value = "id") String itemBankId,
                                                           @RequestParam(value = "name", defaultValue = "") String name);

    /**
     * 根据题库ID获取题型列表.
     *
     * @param itemBankId 题库id
     * @return 题型列表
     */
    @GetMapping(value = "/itemBank/{id}/questiontypes")
    List<QuestionType> getListByItemBankId(@PathVariable(value = "id") String itemBankId);

    /**
     * 新增题型.
     *
     * @param itemBankId 所属题库id
     * @param model      题型传输模型
     * @return the return model
     */
    @PostMapping(value = "/itemBank/{id}/questiontype")
    ReturnModel insert(@PathVariable(value = "id") String itemBankId, @RequestBody QuestionTypeDto model);

    /**
     * 修改题型
     *
     * @param id         题型
     * @param itemBankId 所属题库id
     * @param model      the model
     * @return the int
     */
    @PutMapping(value = "/itemBank/{id}/questiontype/{questionTypeId}")
    int update(@PathVariable(value = "questionTypeId") String id, @PathVariable(value = "id") String itemBankId, @RequestBody QuestionTypeDto model);

    /**
     * 更新题型状态.
     *
     * @param id         题型
     * @param itemBankId 所属题库id
     * @return the int
     */
    @PutMapping(value = "/itemBank/{id}/questiontype/{questionTypeId}/status")
    int changeStatus(@PathVariable(value = "questionTypeId") String id, @PathVariable(value = "id") String itemBankId);

    /**
     * 删除题型.
     *
     * @param id         题型ID
     * @param itemBankId 所属题库ID
     * @return the int
     */
    @DeleteMapping(value = "/itemBank/{id}/questiontype/{questionTypeId}")
    int delete(@PathVariable(value = "questionTypeId") String id, @PathVariable(value = "id") String itemBankId);

    /**
     * 恢复标记删除的修改题型使用关系状态.
     *
     * @param id         题型ID
     * @param itemBankId 所属题库ID
     * @return the int
     */
    @DeleteMapping(value = "/itemBank/{id}/questiontype/{questionTypeId}/rollback")
    int deleteRollback(@PathVariable(value = "questionTypeId") String id, @PathVariable(value = "id") String itemBankId);
}
